<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        /*创建元素分3步
        1.调用createElement创建元素
        2.为该元素设置传统样式或css
        3.将该元素附加到其父元素当中*/
        function addElement(){
            var myImage = document.createElement('img');
            myImage.src = '../snake/image/bg.png';
            document.body.appendChild(myImage);
        }
    </script>
</head>
<body onload="addElement()">
    
</body>
</html>